This C++ program allows the user to input four integer values, adds them, and displays the total.
#include<iostream.h>
#include<conio.h>
main() {
int a, b, c, d, total;
// Prompt user for input
cout << "Marks of A: ";
cin >> a;
cout << "\nMarks of B: ";
cin >> b;
cout << "\nMarks of C: ";
cin >> c;
cout << "\nMarks of D: ";
cin >> d;
// Calculate the total
total = a + b + c + d;
// Output the result
cout << "\nTotal is: " << total << endl;
getch();
}
When you run the program and enter the marks for A, B, C, and D, it will display the total marks:
Marks of A: 85
Marks of B: 90
Marks of C: 78
Marks of D: 92
Total is: 345